﻿using System.Reflection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Marbles.CMS.Controls
{
    public partial class AboutDialog : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Resources.CMSResources res = new CMS.Resources.CMSResources();
            imgLogo.ImageUrl = res.CMSLogoURL;
            this.lblRunTimeVer.Text = Marbles.Core.Info.RunTimeVersion.ToString();
            this.lblRuntime.Text = "Something";

            switch (Marbles.Core.Info.RuntimeName)
            {
                case Marbles.Core.RuntimeName.DotGNU: this.lblRuntime.Text = "DotGNU"; break;
                case Marbles.Core.RuntimeName.MicrosoftNet: this.lblRuntime.Text = "Microsoft .Net"; break;
                case Marbles.Core.RuntimeName.Mono: this.lblRuntime.Text = "Mono"; break;
            }

            lblOS.Text = "Electrons";
            
            switch (Marbles.Core.Info.OperationSystemVersion.Platform)
            {
                case PlatformID.MacOSX: lblOS.Text = "Mac OS-X"; break;
                case PlatformID.Unix: lblOS.Text = "Unix"; break;
                case PlatformID.Win32NT: lblOS.Text = "Microsoft Windows NT"; break;
                case PlatformID.Win32S: lblOS.Text = "Microsoft Windows 3.1"; break;
                case PlatformID.Win32Windows: lblOS.Text = "Microsoft Windows"; break;
                case PlatformID.WinCE: lblOS.Text = "Microsoft Windows CE"; break;
                case PlatformID.Xbox: lblOS.Text = "Microsoft Xbox 360"; break;
            }

            lblOS.Text = Environment.OSVersion.VersionString;
            lblVersion.Text = GetCMSVersion();
        }

        public void Show()
        {
            this.pnlAboutDlgPopup.Show();
        }

        public void Hide()
        {
            this.pnlAboutDlgPopup.Hide();
        }

        public static string GetCMSVersion()
        {
            return Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }
    }
}